/****************************************************************************
*                                                                           *
* scdefs.h -- basic wavesimulator definitions                               *
*                                                                           *
* ALaRI 2008												                *
*                                                                           *
****************************************************************************/
#pragma once

#if !defined(__DEFS_H)
#define __DEFS_H

#include <cassert>
#include <cstring>
#include "config.h"

#ifndef NULL
#define NULL    0
#endif

#ifndef FALSE
#define FALSE               0
#endif

#ifndef TRUE
#define TRUE                1
#endif

#if defined(_WIN64)
 typedef unsigned __int64 ULONG_PTR;
#else
 typedef unsigned long ULONG_PTR;
#endif

typedef ULONG_PTR			DWORD_PTR;
typedef unsigned long       DWORD;
typedef int                 BOOL;
typedef unsigned char       BYTE;
typedef unsigned short      WORD;
typedef float               FLOAT;
typedef FLOAT               *PFLOAT;
typedef BYTE				*PBYTE;

typedef int                 INT;
typedef unsigned int        UINT;
typedef unsigned int        *PUINT;

#ifndef max
#define max(__a, __b)       (((__a) > (__b)) ? (__a) : (__b))
#endif

#ifndef min
#define min(__a, __b)       (((__a) < (__b)) ? (__a) : (__b))
#endif

#ifndef MakeRgb
#define MakeRgb(__r, __g, __b) ((unsigned int)((0xff << 24) | (((__r) & 0xff) << 16) \
	| (((__g) & 0xff) << 8) | ((__b) & 0xff)))
#endif 

/* free memory */
#ifndef SafeFree
#define SafeFree(__ptr)	{\
	if((__ptr) != NULL)\
{\
	delete((__ptr));\
	(__ptr) = NULL;\
}\
}

#endif

/* _COUNTOF helper */
#if !defined(CountOf)
#if !defined(__cplusplus)
#define CountOf(_Array) (sizeof(_Array) / sizeof(_Array[0]))
#else
extern "C++"
{
template <typename _CountofType, size_t _SizeOfArray>
char (*__countof_helper(_CountofType (&_Array)[_SizeOfArray]))[_SizeOfArray];
#define CountOf(_Array) sizeof(*__countof_helper(_Array))
}
#endif	/* __cplusplus */
#endif	/* _COUNTOF */ 

#endif /* __DEFS_H */

/****************************************************************************
* End of file																*
****************************************************************************/
